import java.util.*;

public class C {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		int n = sc.nextInt();
		var mp = new HashMap<Integer, Integer>();
		int[] a = new int[n + 10];
		var list = new ArrayList<pair>();
		int ret = 0;
		
		for(int i = 1; i <= n; i ++ ) {
			a[i] = sc.nextInt();
			mp.put(a[i], i); // 表示的是a[i]的位置是i
		}
		for(int i = 1; i <= n; i ++ ) {
			if(a[i] != i ) {
				ret += 1; // 表示的是交换的次数+1
				int pos = mp.get(i);
				mp.put(a[i], pos); // 也就是说a[i] 交换了位置
				int t = a[pos];
				a[pos] = a[i];
				a[i] = t;
				//上面的这个其实是可以去省略的
				pair p = new pair();
				p.x = i;
				p.y = pos;
				list.add(p);
			}
		}
		System.out.print(ret + "\n");
		for(var t : list) {
			System.out.print(t.x +" " + t.y + "\n");
		}
	}
}


class pair {
	int x;
	int y;
}